package com.richpay.basejava.base05;

public class MultiplyDemo {
    public static void main(String[] args) {
        int result = multiply(3);
        System.out.println("result=" + result);
    }

    /**
     计算指定数的阶乘
     multiply(3)=3*multiply(2);
     multiply(2)=2*multiply(1);
     multiply(1)=1

     */
    static int multiply(int n) {
        if (n == 0 || n == 1) {
            System.out.println("n==0||n==1");
            return 1;
        } else {
            System.out.println("n=" + n);
            return n * multiply(n - 1);
        }
    }
}